<script>

export default {
  name: 'InboundRecordLabelList',
  props: {
    dataSource: {
      type: Array,
      default: () => []
    }
  },
  data() {
    return {
      selectedRowKeys: [],
      loading: false,
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 40,
          align: 'center',
          fixed: 'left',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        /*
        {
          title: '入库单号',
          align: 'center',
          dataIndex: 'entryNumber'
        },
         */
        {
          title: '单据号',
          align: 'center',
          dataIndex: 'documentNumber'
        },
        {
          title: '物料编码',
          align: 'center',
          dataIndex: 'materialCode'
        },
        {
          title: '物料名称',
          align: 'center',
          dataIndex: 'materialName'
        },
        {
          title: '规格型号',
          align: 'center',
          dataIndex: 'specificationModel'
        },
        {
          title: '单位',
          align: 'center',
          dataIndex: 'unit_dictText'
        },
        {
          title: '批次号',
          align: 'center',
          dataIndex: 'batchNumber'
        },
        {
          title: '物料批号',
          align: 'center',
          dataIndex: 'materialBatchNumber'
        },
        {
          title: '数量',
          align: 'center',
          dataIndex: 'quantity'
        }
      ]
    }
  },
  methods: {
    onClearSelected() {
      this.selectedRowKeys = []
      this.selectionRows = []
      this.$emit('change', [], [])
    },
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectionRows = selectionRows
      this.$emit('change', selectedRowKeys, selectionRows)
    }
  }
}
</script>

<template>

  <div>
    <div class="ant-alert ant-alert-info" style="margin: 16px 0;">
      <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
      style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
      <a style="margin-left: 24px" @click="onClearSelected">清空</a>
    </div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="inbound_order_item_id"
      class="j-table-force-nowrap1"
      :scroll="{x:true}"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="false"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
    >
    </a-table>
  </div>
</template>

<style scoped>

</style>